package com.itheima.health.controller;

import com.itheima.health.dto.SetmealDTO;
import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.entity.Result;
import com.itheima.health.service.OrderSettingService;
import com.itheima.health.service.SetmealService;
import com.itheima.health.utils.aliyunoss.AliyunUtils;
import com.itheima.health.utils.poi.POIUtils;
import com.itheima.health.utils.redis.RedisUtil;
import com.itheima.health.utils.resources.RedisConstant;
import com.itheima.health.utils.resources.UploadUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;

@RestController
@Api(tags = "预约设置管理开发")
public class OrderSettingController {


    // springmvc  消息转化器   @ResponseBody  默认 全字段序列化

    @Reference
    private OrderSettingService orderSettingService;


    @PostMapping("ordersetting/importOrderSettings")
    @ApiOperation(value = "分页查询功能",notes = "查询所有的检查组列表信息")
    public Result importOrderSettings(@RequestParam("excelFile") MultipartFile file) throws IOException {
    //  file  excel文件---  List<OrderSetting>
        POIUtils.checkFile(file);
        List<String[]> readExcelList = POIUtils.readExcel(file);
        //  string[0]   string[1]
        return new Result(orderSettingService.importOrderSettings(readExcelList));
    }

    @GetMapping("ordersetting/findSettingData/{year}/{month}")
    @ApiOperation(value = "分页查询功能",notes = "查询所有的检查组列表信息")
    public Result findSettingData(@PathVariable("year") int year ,@PathVariable("month")int month) throws IOException {
        return new Result(orderSettingService.findSettingData(year,month));
    }

    @PutMapping("ordersetting/updateNumberByOrderDate/{number}/{orderdate}")
    @ApiOperation(value = "分页查询功能",notes = "查询所有的检查组列表信息")
    public Result updateNumberByOrderDate(@PathVariable("number") int number ,@PathVariable("orderdate")String orderdate) throws IOException {
        return new Result(orderSettingService.updateNumberByOrderDate(number,orderdate));
    }

}





